baubs git
src/platform/index.ts refactor/extract-sub-components (095c879e) Text, 1.06 KB
import type { IStorageService } from "./interfaces/IStorageService";
import type { IFileService } from "./interfaces/IFileService";
import { BrowserStorageService } from "./browser/BrowserStorageService";
import { BrowserFileService } from "./browser/BrowserFileService";
import { ElectronStorageService } from "./electron/ElectronStorageService";
import { ElectronFileService } from "./electron/ElectronFileService";
/**
* Detect if running in Electron
*/
export function isElectron(): boolean {
return !!(
typeof window !== "undefined" &&
window.process &&
window.process.type === "renderer"
);
}
/**
* Create storage service based on platform
*/
export function createStorageService(): IStorageService {
if (isElectron()) {
return new ElectronStorageService();
} else {
return new BrowserStorageService();
}
}
/**
* Create file service based on platform
*/
export function createFileService(): IFileService {
if (isElectron()) {
return new ElectronFileService();
} else {
return new BrowserFileService();
}
}
Served by rngit 1.3.3 - Generated in 0.06s